home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / FADERS.ZIP / FADEUNIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-25  |  3.3 KB  |  119 lines

  1. Unit FADEUNIT;
  2. {$D-,S-}
  3.  
  4. Interface
  5.  
  6. const
  7.  Palette : array[0..767] of Byte = (
  8.          0,0,0,0,0,42,0,42,0,0,42,42,42,0,0,42,0,42,42,42,0,42,42,42,0,0,21,0,0,63,0,42,
  9.          21,0,42,63,42,0,21,42,0,63,42,42,21,42,42,63,0,21,0,0,21,42,0,63,0,0,63,42,42,
  10.          21,0,42,21,42,42,63,0,42,63,42,0,21,21,0,21,63,0,63,21,0,63,63,42,21,21,42,21,
  11.          63,42,63,21,42,63,63,21,0,0,21,0,42,21,42,0,21,42,42,63,0,0,63,0,42,63,42,0,63,
  12.          42,42,21,0,21,21,0,63,21,42,21,21,42,63,63,0,21,63,0,63,63,42,21,63,42,63,21,21,
  13.          0,21,21,42,21,63,0,21,63,42,63,21,0,63,21,42,63,63,0,63,63,42,21,21,21,21,21,63,
  14.          21,63,21,21,63,63,63,21,21,63,21,63,63,63,21,63,63,63,0,0,0,0,0,0,0,0,0,0,0,0,0,
  15.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  16.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  17.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  18.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  19.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  20.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  21.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  22.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  23.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  24.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  25.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  26.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  27.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  28.          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  29.          0,0,0);
  30.  
  31. Var Pal_Buf: Array[0..1535] of byte;
  32.  
  33. {$L FADE}
  34. Procedure W_Palette;
  35. Procedure FadeIn;
  36. Procedure FadeOut;
  37. Procedure FI;
  38. Procedure FO;
  39.  
  40. Implementation
  41.  
  42. procedure FI; external {FADE};
  43. procedure FO;external {FADE};
  44.  
  45. Procedure W_Palette;assembler;
  46.  ASM
  47.                 lea si,[pal_buf]
  48.                 mov bh,0
  49.                 mov bl,2
  50.  
  51.                 mov cx,128*3
  52. @s:
  53.                 mov dx, 03DAh
  54.     @v1:
  55.         in    al, dx
  56.         test   al,08h
  57.         jnz    @v1
  58.     @v2:
  59.         in     al, dx
  60.         test   al,08h
  61.         jz     @v2
  62.  
  63.  
  64.                 mov al,bh
  65.         mov dx,3c8h
  66.                 push cx
  67.         out dx,al
  68.         inc dx
  69.         rep outsb
  70.                 pop cx
  71.                 add bh,128
  72.                 dec bl
  73.                 jnz @s
  74.  end;
  75.  
  76. Procedure FadeIn;
  77. var
  78.   ColorOn : Longint;
  79.   bp      : byte;
  80.  
  81. Begin
  82. For bp := 0 to 31 do Begin
  83.    asm
  84.     mov ax,seg Pal_buf
  85.     mov ds,ax
  86.     mov si,offset pal_buf
  87.  
  88.     mov ax,seg Palette
  89.     mov es,ax
  90.     mov di,offset palette
  91.  
  92.    end;
  93.    FI;
  94.  W_Palette;
  95.  end;
  96. end;
  97.  
  98. Procedure FadeOut;
  99. var
  100.   ColorOn : Longint;
  101.   bp      : byte;
  102.  
  103. Begin
  104. For ColorOn := 0 to 767 do
  105.  Begin
  106.   Pal_Buf[ColorOn] := Palette[ColorOn];
  107.  end;
  108. For bp := 0 to 31 do Begin
  109.    Asm
  110.     mov ax,seg Pal_buf
  111.     mov ds,ax
  112.     mov si,offset pal_buf
  113.    end;
  114.    FO;
  115.    W_Palette;
  116.  end;
  117. end;
  118. End.
  119.